FROM alpine as builder
ENV base=https://downloads.openwrt.org/releases/21.02.7/targets/x86/64/
ENV file=openwrt-21.02.7-x86-64-rootfs.tar.gz
RUN wget -q "${base}${file}"
RUN mkdir /rootfs && tar xf "$file" -C /rootfs

FROM scratch as base
COPY --from=builder /rootfs/ /
CMD ["/bin/sh"]

FROM base
RUN mkdir /var/lock /home \
 && opkg update && opkg install shadow-useradd \
 && useradd -m user
ENV SH=/bin/sh
